package com.school.entity;

import com.school.course.Course; // 关联Course类（跨包访问，需public修饰）

public class Teacher extends Person {
    // 特有属性：所授课程
    private Course taughtCourse;

    // 子类构造方法：通过super()调用父类构造，初始化共性属性
    public Teacher(String teacherId, String teacherName, String gender) {
        super(teacherId, teacherName, gender); // 父类Person的构造参数：id、name、gender
    }

    // 特有业务方法：开课
    public void openCourse(Course course) {
        this.taughtCourse = course;
        System.out.println("\n教师[" + super.name + "]成功开设课程[" + course.getCourseName() + "]");
    }

    // 重写父类方法：扩展为“打印教师信息+所授课程”
    @Override
    public void printInfo() {
        super.printInfo(); // 调用父类方法，打印基础信息
        if (taughtCourse != null) {
            System.out.println("所授课程：" + taughtCourse.getCourseName() + "（" + taughtCourse.getCourseId() + "）");
        } else {
            System.out.println("所授课程：暂未开课");
        }
    }

    // Getter：外部（如Student的printSchedule）需获取教师的课程信息
    public Course getTaughtCourse() {
        return taughtCourse;
    }
}